// Copyright (c) 2020 Presto Labs Pte. Ltd.
// Author: donggu
// c++ feed-relay-client-poc.cc -lzmqpp -lzmq

#include <cstdio>
#include <iostream>
#include <string>

#include <zmqpp/zmqpp.hpp>

int main() {
  // const std::string endpoint = "tcp://127.0.0.1:5124";
  const std::string endpoint = "tcp://18.163.136.233:5124";
  zmqpp::context context;
  zmqpp::socket socket(context, zmqpp::socket_type::sub);
  socket.connect(endpoint);
  socket.subscribe("Futures.Okex.v3.realtime_light_bbo:LTC-USD.QUARTER");

  while (true) {
    zmqpp::message message;
    socket.receive(message);

    // Read as a string
    std::string topic;
    std::string rt;
    std::string msg;
    message >> topic;
    printf("%s\n", topic.c_str());
    message >> rt;
    printf("%s\n", rt.c_str());
    message >> msg;
    printf("%s\n", msg.c_str());
  }
  socket.disconnect(endpoint);
  return 0;
}
